//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Data;
using CommunityServer.Components;

namespace CommunityServer.Galleries.Components
{
	/// <summary>
	/// Summary description for GalleryApplication.
	/// </summary>
	public class GalleryApplication : CSApplicationData
	{
		public GalleryApplication()
		{
			//
			// TODO: Add constructor logic here
			//
		}

        public override string Home
        {
            get{ return GalleryUrls.Instance().Home;}
        }

        public override string SectionUrl(IContent ic)
        {
            if(ic != null)
            {
                IndexPost ip = ic as IndexPost;
				if(ip != null)
					return GalleryUrls.Instance().ViewGallery(ip.ApplicationKey);
	
                GalleryPost gp = ic as GalleryPost;
                if(gp != null)
                    return GalleryUrls.Instance().ViewGallery(gp.Section.ApplicationKey);
            }

            return string.Empty;
        }

		public override string PostName
		{
			get
			{
				return ResourceManager.GetString("GalleryApplication_Post");
			}
		}

		public override string SectionName
		{
			get
			{
				return ResourceManager.GetString("GalleryApplication_Section");
			}
		}

		public override string GroupName
		{
			get
			{
				return ResourceManager.GetString("GalleryApplication_Group");
			}
		}

		public override string CategoryName
		{
			get
			{
				return ResourceManager.GetString("GalleryApplication_Category");
			}
		}

		#region Favorite Text

		public override string AddFavoritePostText
		{
			get
			{
				return ResourceManager.GetString("Favorites_Gallery_AddPost");
			}
		}

		public override string RemoveFavoritePostText
		{
			get
			{
				return ResourceManager.GetString("Favorites_Gallery_RemovePost");
			}
		}

		public override string AddFavoriteSectionText
		{
			get
			{
				return ResourceManager.GetString("Favorites_Gallery_AddSection");
			}
		}

		public override string RemoveFavoriteSectionText
		{
			get
			{
				return ResourceManager.GetString("Favorites_Gallery_RemoveSection");
			}
		}

		#endregion

	    public override IList Groups()
	    {
	        return GalleryGroups.GetGroups(true,false,false);
	    }

	    public override IList Sections()
	    {
	        return Galleries.GetGalleries(true,false);
	    }

	    public override IList SectionsByGroup(int groupID)
	    {
	        return Galleries.GetGalleriesByGroupID(groupID,false,true,false);
	    }

	    public override ApplicationType ApplicationType
	    {
	        get { return ApplicationType.Gallery; }
	    }

	    public override string Name
	    {
	        get { return ResourceManager.GetString("photos");}
	    }

	    public override string Url(Post post)
	    {
	        return GalleryUrls.Instance().ViewPicture(post.Section.ApplicationKey, post.PostID);
	    }

	    public override Post InstantiatePost(IDataReader dr)
	    {
	        return GalleryDataProvider.PopulateGalleryPostFromIDataRecord(dr);
	    }

		public override Post GetPost(int postID)
		{
			return GalleryPosts.GetPicture(postID);
		}

        public override bool Enabled
        {
            get { return GalleryConfiguration.Instance().Enabled;}
        }

        public override void SetEnabledStatus(bool enabled)
        {
            GalleryConfiguration config = GalleryConfiguration.Instance(false);
            config.Enabled = enabled;
            config.Save();
       }

	}
}
